#ifndef DOWNLOADITEMCONTROLLER_H
#define DOWNLOADITEMCONTROLLER_H
#include <QString>
#include <QDateTime>
#include <QWebEngineDownloadRequest>
class historyitemmodel;
class QWidget;
class QListWidgetItem;
//class downloaditemwidget;
class downloaditemcontroller: public QObject
{
    Q_OBJECT
public:
    explicit downloaditemcontroller(QWebEngineDownloadRequest *download, QObject *parent = nullptr);
    //~downloaditemcontroller();

    historyitemmodel *historyItem;
    QListWidgetItem *widgetItem;
    QWebEngineDownloadRequest *downloadRequest;//download需要对视图进行封装

    QString setTitle();
    qreal getTotalBytes();
    qreal getReceivedBytes();
    bool isPaused();
    QIcon icon();
    QString withUnit(qreal bytes);
    QString secsToTime(int s);
    bool fileExists();
    //数据库相关
    void initializeModel(QString downloadFileDir, QString downloadFileName, QUrl url, QDateTime curTime, qreal totalBytes);
    void insert();




signals:
    void deleteClicked(downloaditemcontroller *newcontroller);

public slots:
    //void updateWidget();
    void pause();
    void resume();
    void cancel();
    void openfolder();
    bool deletefile();
    void openfile();
    void restart();
    void changeState();

};

#endif // DOWNLOADITEMCONTROLLER_H
